
// window.onload = function () {



frame.toFront();
label[0].toFront();
label[1].toFront();
blanket.toFront();
S763.bgp.toFront();
K1907.bgp.toFront();
BG_mouseMove=function(){
    // $("#time").html(TIMELINE.mov(GLOBAL.mX+dx));
    // $("#time").html(event.x+" "+event.y);
    document.getElementById("time").innerHTML=event.offsetX+" "+event.offsetY;
}
BG_mouseDown=function(x,y){
    GLOBAL.mX=x;
    GLOBAL.mY=y;
}
BG_mouseUp=function(event){
    S763.SubPath(event.offsetX);
    // console.log(event.x,event.y);
    // alert((document.getElementById("time")).innerHTML);
}
BACK.mousemove(BG_mouseMove).toFront();
BACK.click(BG_mouseUp);
// BACK.drag(BG_mouseMove,BG_mouseDown,BG_mouseUp);

var count=480;
var TIMER;
var TALK_TIME=[];
var PAUSED=false;
$("#ctrl1").click(function(){
    count=480;
    clearTimeout(TIMER);
    S763.GotoTime(480).ClearAll().UpdateTimeLine().MakeUseable();
    K1907.GotoTime(480).ClearAll().UpdateTimeLine().MakeUseable();
});
$("#ctrl2").click(function(){
    S763.GotoTime(0).MakeUseable();
    K1907.GotoTime(0).MakeUseable();
});
$("#ctrl3").html("pause").click(function(){
    if (PAUSED==true){
	PAUSED=false;
	$("#talk").children().each(function(){$(this).hide()});
	test();
	return;
    }
    var x=TALK_TIME.length;
    for (var i=0;i<x;i++){
	clearTimeout( TALK_TIME[i] );
    }
    TALK_TIME=[];
    clearTimeout(TIMER);
    PAUSED=true;
    // S763.GotoTime(0).MakeUseable();
    // K1907.GotoTime(0).MakeUseable();
});
$("#ctrl").html("开始演示").click(test);
function test(){
    // S763.GotoTime(200);
    // S763.SubPath(0.5);
    K1907.GotoTime(count).UpdateTimeLine().GetIMPoint().ShowDialog(count);
    S763.GotoTime(count).UpdateTimeLine().GetIMPoint().ShowDialog(count);;
    TIMELINE.SetClock(count);
    if (count<=0){
	count=480;
	clearTimeout(TIMER);
	return;
    }
    count-=5;
    TIMER=setTimeout("test()",800);
}
$("#F1907").hide();
$("#F763").hide();
$("#ATC").hide();
$("#msg").hide();
$("#warning").hide();
HTML_INIT();
function HTML_INIT(){
    for(var i=0;i<DATA.length;i++){
	var d=DATA[i];
	var time=d["beginTime"];

	function ifOK(a){
	    if ((a!="")&&(a!=null)&&(a!=undefined)) return a;
	    else return false;
	}

	var name=763;
	var a=ifOK(d["contentOf763"]);
	if (a==false){
	    a=ifOK(d["contentOf1907"]);
	    name=1907;
	    if (a==false){
		a=ifOK(d["contentOfATC"]);
		if (a==false) continue;
		name="ATC";
	    }
	}
	var ttt=$("#init").clone();
	ttt.hide().attr({
	    "id":name+"_"+i,
	    "name":name,
	    "time": time,
	}).css("float","left");
	ttt.find("img").attr({"width":60,"src":name+".png"}).css({
	    "margin-top":"0px"
	});
	ttt.find("div:first").css({
	    "width":"60px",
	    "float":"left"
	});
	ttt.find("div:last").css({
	    "margin":"5px",
	    "width":"200px",
	    "float":"left"
	});
	ttt.find("p:first").html(name).css("text-align","center");
	ttt.find("p:last").html(a);
	$("#talk").append(ttt);
    }
}

$("#ctrl1").css({
    "width":"30px"
});

$("#ctrl2").css({
    "width":"30px"
});

$("#ctrl3").css({
    "width":"30px"
});
$("#init").hide();